import java.io.*;

	/**
	* @author Joshua Oberle.
	*/

public class LogTarReader{

	/**
	* This passes a tarball to the LogFileReader class.
	*
	* This will only work on linux. It is provided simply for convenience.
	*
	* @param args[0] The name of the tarball to feed to LogFileReader.
	*/

	public static void main(String[] args){
		String s = null;
		String[] cmdarray = new String[5];
		try{
			String[] cmd = {"/bin/sh","-c","tar --to-stdout -zxf " + args[0] + " | java -cp .:maxmindgeoip.jar LogFileReader"};
			Process p = Runtime.getRuntime().exec(cmd);
			BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
			BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
			
		        while ((s = stdInput.readLine()) != null) {
                		System.out.println(s);
            		}

	            	while ((s = stdError.readLine()) != null) {
                		System.out.println(s);
            		}
		}catch(Exception e){
			e.printStackTrace();
		}
	}//main(String[])

}//class LogFileReader